#include <iostream>
#include "CBufferedStream.h"

using namespace std;

int main(int argc,char *argv[])
{

	if(argc<2) {
		cout << "Usages : " << argv[0] << " -f <file> or -p" << endl;
		exit(-1);
	}


	if(strcmp(argv[1],"-f")==0) {
		CBufferedStream buf(argv[2]);
		istream is(&buf);

		char c;
		while(!is.eof()) {
			if(!is.get(c).fail()) {
				if(c=='\t') {
					cout << '\t';
				}
				else if(c=='\n') {
					cout << '\n';
				}
				else cout << c;
			}
		}
	}

	else if(strcmp(argv[1],"-p")==0) {
		streambuf *buff = cin.rdbuf();
		istream is(buff);

		char c;
		while(!is.eof()) {
			if(!is.get(c).fail()) cout << c;
		}
	}
}
